package com.example.toutiao.view

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.Window
import androidx.fragment.app.DialogFragment

abstract class BaseDialogFragment:DialogFragment() {
    private var rootView: View?=null
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        dialog!!.requestWindowFeature(Window.FEATURE_NO_TITLE)
        dialog!!.setCanceledOnTouchOutside(true)
        dialog!!.setCancelable(true)
        if(rootView==null){
            rootView=inflater.inflate(getLayout(),container,true)
            val views:View?=rootView
            initView(views!!)
            initData()
        }
        return rootView
//        return super.onCreateView(inflater, container, savedInstanceState)
    }
    protected abstract fun initData()
    protected abstract fun initView(view:View)
    protected abstract fun getLayout():Int
}